import { getScreenOtherData } from "@/api/dataAsset";
import { ScreenOtherRes } from "@/api/types/dataAsset";
import { EChartsOption } from "echarts";
import { useEffect, useState } from "react";
import { createOtherEchartsOption } from "../config/echarts";

// 美团商家数据采集总量

// TOP10其他数据采集量
export function useOtherData() {
  const [otherData, setOtherData] = useState<ScreenOtherRes>([]),
    [echartsOption, setEchartsOption] = useState<EChartsOption>({})

  console.log(otherData)

  const request = async () => {
    try {
      const res = await getScreenOtherData()

      if (res.code === 200) {
        setOtherData(res.data)
        setEchartsOption(createOtherEchartsOption(res.data))
      }
    } catch (error) {
      console.error(error)
    }
  }

  useEffect(() => {
    request()
  }, [])

  return [
    echartsOption
  ] as const
}